﻿using BestTrader.Cms.Core.ApiModels;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BestTrader.Cms.WebApi
{
    /// <summary>
    /// Api 基类控制器
    /// </summary>
    public class BaseController: Controller
    {
      
        /// <summary>
        /// 带API版本号的数据返回
        /// </summary>
        public JsonResult Json<T>(T data)
        {
            var newData = new ApiData<T>(data);
            return base.Json(newData);
        }

        /// <summary>
        /// 带API版本号的数据返回
        /// </summary>
        public JsonResult Json<T>(T data, bool success, int code, string message)
        {
            var newData = new ApiData<T>(data, success, code, message);
            return base.Json(newData);
        }

        public JsonResult ToJson<T>(ApiData<T> data)
        {
            return base.Json(data);
        }
    }
}
